package com.txts.road.admin.dabenying.controller;

import com.txts.base.common.domain.PageResult;
import com.txts.base.common.domain.ResponseDTO;
import com.txts.road.admin.common.annotation.Anonymous;
import com.txts.road.admin.common.annotation.Log;
import com.txts.road.admin.common.core.controller.BaseController;
import com.txts.road.admin.common.core.domain.AjaxResult;
import com.txts.road.admin.common.core.page.TableDataInfo;
import com.txts.road.admin.common.enums.BusinessType;
import com.txts.road.admin.common.utils.poi.ExcelUtil;
import com.txts.road.admin.dabenying.domain.BasecampInfo;
import com.txts.road.admin.dabenying.service.IBasecampInfoService;
import com.txts.road.admin.raceSys.domain.RaceSys;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import jakarta.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 大本营信息Controller
 *
 * @author ruoyi
 * @date 2025-05-16
 */
@RestController
@RequestMapping("/DabenyingSys/Dabenyinginfo")
@Tag(name = "大本营接口")
public class BasecampInfoController extends BaseController {
    @Resource
    private IBasecampInfoService basecampInfoService;

    /**
     * 查询大本营信息列表
     */
    @Anonymous
    @GetMapping("/list")
    @Operation(summary = "查询大本营信息列表", description = "根据条件查询大本营信息列表")
    public ResponseDTO<PageResult<BasecampInfo>> list(BasecampInfo basecampInfo) {
        startPage();
        List<BasecampInfo> list = basecampInfoService.selectBasecampInfoList(basecampInfo);
        return getDataTable(list);
    }

    /**
     * 导出大本营信息列表
     */
    @PreAuthorize("@ss.hasPermi('DabenyingSys:Dabenyinginfo:export')")
    @Log(title = "大本营信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @Operation(summary = "导出大本营信息列表", description = "导出大本营信息列表")
    public void export(HttpServletResponse response, BasecampInfo basecampInfo) {
        List<BasecampInfo> list = basecampInfoService.selectBasecampInfoList(basecampInfo);
        ExcelUtil<BasecampInfo> util = new ExcelUtil<BasecampInfo>(BasecampInfo.class);
        util.exportExcel(response, list, "大本营信息数据");
    }

    /**
     * 获取大本营信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('DabenyingSys:Dabenyinginfo:query')")
    @GetMapping(value = "/{name}")
    @Operation(summary = "获取大本营信息详细信息", description = "根据名称获取大本营信息详细信息")
     public ResponseDTO<Object> getInfo(@PathVariable("name") String name) {
        return success(basecampInfoService.selectBasecampInfoByName(name));
    }

    /**
     * 新增大本营信息
     */
    @PreAuthorize("@ss.hasPermi('DabenyingSys:Dabenyinginfo:add')")
    @Log(title = "大本营信息", businessType = BusinessType.INSERT)
    @PostMapping
    @Operation(summary = "新增大本营信息", description = "新增大本营信息")
    public ResponseDTO<Object>add(@RequestBody BasecampInfo basecampInfo) {
        return toAjax(basecampInfoService.insertBasecampInfo(basecampInfo));
    }

    /**
     * 修改大本营信息
     */
    @PreAuthorize("@ss.hasPermi('DabenyingSys:Dabenyinginfo:edit')")
    @Log(title = "大本营信息", businessType = BusinessType.UPDATE)
    @PutMapping
    @Operation(summary = "修改大本营信息", description = "修改大本营信息")
    public ResponseDTO<Object>edit(@RequestBody BasecampInfo basecampInfo) {
        return toAjax(basecampInfoService.updateBasecampInfo(basecampInfo));
    }

    /**
     * 删除大本营信息
     */
    @PreAuthorize("@ss.hasPermi('DabenyingSys:Dabenyinginfo:remove')")
    @Log(title = "大本营信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{names}")
    @Operation(summary = "删除大本营信息", description = "删除大本营信息")
    public ResponseDTO<Object>remove(@PathVariable String[] names) {
        return toAjax(basecampInfoService.deleteBasecampInfoByNames(names));
    }
}
